<?php
namespace app\common\model;

class WorkerBank extends Base
{
    protected $name = 'worker_bank';

    public function getSexAttr($val)
    {
        switch ($val) {
            case 1: return '男';
            case 2: return '女';
            default: return '保密'; break;
        }
    }

    public function getFaceImgAttr($val)
    {
        if(!$val){
            return '';
        }

        return config('app.url') . $val;
    }

    public function getCateIdAttr($val)
    {
        if(!$val){
            return '-';
        }

        $ids = explode(',', $val);
        
        $list = (new WorkerCate)->getCol([['id', 'in', $ids]], 'name');

        if($list['code'] != 'ok'){
            return '-';
        }

        return implode('、', $list['data']);
    }

    /** 昨日人工列表 */
    public function getYesterdayList($where = [], $page = 1, $limit = 10, $field = '*', $order = 'id')
    {
        return $this->where($where)
            ->whereDay('create_time', 'yesterday')
            ->field($field)
            ->page($page, $limit)
            ->order($order)
            ->select();
    }
}